Repository navigation
feat: [SDK-5858] add OneSignal to iOS builds as a Swift package (1/2) - #920
fadi-george wants to merge 1 commit into
Conversation
…aPods CocoaPods trunk is read-only from Dec 2, 2026. The iOS post-processor now links the OneSignal-XCFramework Swift package through Unity 6's PBXProject APIs, and the generated iOS dependencies file is removed. All packages require Unity 6, and the iOS package no longer depends on External Dependency Manager. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c530210 to
b4dea68
Compare
abdulraqeeb33
left a comment
There was a problem hiding this comment.
The fresh Replace export looks right. Product names match OneSignal-XCFramework 5.8.1, and a second pass keeps one package reference. Two things need to change before this lands.
Append never links an existing NSE. AddNotificationServiceExtension returns at BuildPostProcessor.cs:201 when OneSignalNotificationServiceExtension is already in the project. AddProduct(..., "OneSignalExtension") is at line 231, after that return. The pod edit this replaces ran before the return, and this PR deletes the generated pod XML, so an Append from a v5 export keeps the extension and then links nothing. NotificationService.swift imports OneSignalExtension. A Replace creates the target, which is the path the manual test ran (BuildOptions.None). Move the AddProduct call above the return. The write at the bottom of OnPostprocessBuild saves it.
The demo widget has the same hole at examples/demo/Assets/App/Editor/iOS/BuildPostProcessor.cs:208 (the link is at line 242). That post-processor has to WriteToFile before returning. The sound and icon steps reload the project from disk.
iOS-only projects do not compile. OneSignal.iOS.Editor.asmdef:5 still references Unity.ExternalDependencyManager.Editor. Nothing in that assembly uses it, and the iOS package no longer depends on EDM. Core does not pull EDM in. Without the Android package, Unity drops OneSignal.iOS.Editor and the post-processor never runs. autoReferenced: true takes the default editor assembly with it. Delete that reference.
Not blocking: with location turned off, Append leaves a previously linked OneSignalLocation in place (BuildPostProcessor.cs:305). A Replace omits it. The README already says to delete the Xcode project when toggling the flag.
Nit: examples/demo/run-ios.sh:186 and examples/demo-no-location/run-ios.sh:117 expand xcodebuild $CONTAINER unquoted, so a project path with a space splits. e2e.yml already uses an array.
Description
One Line Summary
Add the OneSignal iOS SDK to exported Xcode projects as a Swift package instead of installing it through CocoaPods, and require Unity 6 for v6.
Details
Motivation
The CocoaPods trunk is read-only from Dec 2, 2026, so new
OneSignalXCFrameworkversions can't be published there. Unity 6'sPBXProjecthas Swift package APIs (AddRemotePackageReferenceAtVersion,AddRemotePackageFrameworkToProject). We chose these over bundling the XCFrameworks, which would add about 59 MB to the package and a copy step to every release. This is a breaking change, so it ships with v6.Scope
OneSignalSwiftPackage.AddProduct(project, targetGuid, product)(iOS editor). It adds theOneSignal-XCFrameworkpackage reference pinned toVersionand links a product to a target. It's idempotent on Append builds and when called from several post-processors, because Unity's APIs don't deduplicate. It re-pins an older version.BuildPostProcessor:OneSignalFrameworkandOneSignalInAppMessages, plusOneSignalLocationunless location is disabled.OneSignalExtension.OneSignaliOSDependenciesno longer writes the EDMiosPodXML. It deletes the previously generated file, so upgraded projects don't install the pods alongside the package.6000.0/23f1, and the validator enforces it.com.onesignal.unitysdk.iosno longer depends on Unity EDM. The validator requires EDM for Android only.OneSignalFrameworkthrough the helper.run-ios.shandclean.shdrop the CocoaPods steps.pod install, because the Android package pulls it in. So the scripts and E2E build the workspace when it exists.pod install. The release PR workflow bumpsOneSignalSwiftPackage.csand checks that the OneSignal-XCFramework release exists.Unity EDM 2.0's own
<remoteSwiftPackage>support isn't used: it only links UnityFramework (not the app or NSE), and it can be turned off in EDM's settings.Stack:
Testing
Unit testing
There's no Unity test harness for the editor scripts. I ran
OneSignalSwiftPackageagainst a real exported pbxproj with the Unity 6 Xcode API outside Unity: running it twice keeps 1 reference and the same product links, and an older pinned version is re-pinned.Manual testing
On Unity 6000.4.11f1 and Xcode, using
examples/demoon this branch:The publishing tools package was removed locally because it needs a Hub sign-in; that change is not committed.
dotnet csharpier check .andvalidate-unity-distribution.pypass.Affected code checklist
Checklist
Overview
Testing
Final pass
🤖 Generated with Claude Code